package com.jswdwsx.esign.protocol.request

/**
E签宝一步发起签署接口请求
+--platformSign	是否平台自动签署，默认为对接平台的用户签署	body	false	boolean
+--signOrder	签署方签署顺序，默认1,且不小于1，顺序越小越先处理	body	false	int32
+--signerAccount	签署方账号信息（平台自动签署时忽略本参数）	body	false	object
+--+--signerAccountId	签署操作人个人账号标识，即操作本次签署的个人	body	false	string
+--+--authorizedAccountId	签约主体账号标识，即本次签署对应任务的归属方，默认是签署操作人个人	body	false	string
+--signfields	签署文件信息	body	false	array
+--+--autoExecute	是否自动执行，默认false（如果平台自动签署，必须设置为true）	body	false	boolean
+--+--actorIndentityType	机构签约类别，当签约主体为机构时必传：2-机构盖章；	body	false	string
+--+--fileId	文件fileId	body	true	string
+--+--sealId	印章id	body	false	string
+--+--sealType	签署方式，个人签署时支持多种签署方式，0-手绘签名 ，1-个人签章盖章，多种类型时逗号分割，为空不限制	body	false	string
+--+--signType	签署类型，0-不限，1-单页签署，2-骑缝签署，默认1	body	false	int32
+--+--posBean	签署区位置信息（signType为1时, 页码和XY坐标不能为空, signType为2时, 页码和Y坐标不能为空）	body	false	object
+--+--+--posPage	页码信息，当签署区signType为2时, 页码可以'-'分割指定页码范围, 其他情况只能是数字	body	false	string
+--+--+--posX	x坐标	body	false	float
+--+--+--posY	y坐标	body	false	float
+--+--width	签署区的宽度	body	false	int32
+--+--signDateBeanLocked	是否添加签署日期，默认不添加签署日期，则签署人可编辑印章自主添加日期；如指定添加签署日期，则签署人不可删除日期	body	false	boolean
+--+--signDateBean	签署日期信息	body	false	object
+--+--+--fontSize	签章日期字体大小	body	false	int32
+--+--+--format	签章日期格式	body	false	string
+--+--+--posPage	页码信息，autoExecute是否自动执行为true时，并且需要展示签署日期，则需要指定日期盖章页码 ，默认当前页	body	false	int32
+--+--+--posX	x坐标 ，autoExecute是否自动执行为true时，并且需要展示签署日期，则需要指定日期盖章位置 ，默认为0	body	false	float
+--+--+--posY	y坐标 ，autoExecute是否自动执行为true时，并且需要展示签署日期，则需要指定日期盖章位置 ，默认为0	body	false	float
+--thirdOrderNo	第三方流水号	body	false	string
 */
data class CreateFlowOneStepReq(
    val docs: Array<Doc>,
    val flowInfo: FlowInfo,
    val signers: Array<OneStepSigner>
) {
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as CreateFlowOneStepReq

        if (!docs.contentEquals(other.docs)) return false
        if (flowInfo != other.flowInfo) return false
        if (!signers.contentEquals(other.signers)) return false

        return true
    }

    override fun hashCode(): Int {
        var result = docs.hashCode()
        result = 31 * result + flowInfo.hashCode()
        result = 31 * result + signers.contentHashCode()
        return result
    }
}

data class FlowInfo(
    var autoArchive: Boolean,
    var autoInitiate: Boolean = true,
    var businessScene: String,
    var configInfo: ConfigInfo,
    var contractValidity: Long? = null,
    var contractRemind: Int? = null,
    var signValidity: Long? = null,
    var initiatorAccountId: String? = null,
    var initiatorAuthorizedAccountId: String? = null
)

data class OneStepSigner(
    val platformSign: Boolean,
    val signOrder: Int,
    val signerAccount: OneStepSignerAccount?,
    var signfields: Array<OneStepSignField>? = null
) {
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as OneStepSigner

        if (platformSign != other.platformSign) return false
        if (signOrder != other.signOrder) return false
        if (signerAccount != other.signerAccount) return false
        if (signfields != null) {
            if (other.signfields == null) return false
            if (!signfields!!.contentEquals(other.signfields!!)) return false
        } else if (other.signfields != null) return false
        return true
    }

    override fun hashCode(): Int {
        var result = platformSign.hashCode()
        result = 31 * result + signOrder
        result = 31 * result + (signerAccount?.hashCode() ?: 0)
        result = 31 * result + (signfields?.contentHashCode() ?: 0)
        return result
    }
}

data class OneStepSignerAccount(
    val signerAccountId: String,
    val authorizedAccountId: String
)

data class OneStepSignField(
    val autoExecute: Boolean,
    val actorIndentityType: String,
    val fileId: String,
    val sealId: String?,
    val signType: Int,
    val sealType: String?,
    val posBean: OneStepPosBean,
    val width: Float?
)

data class OneStepPosBean(
    val posPage: String,
    val posX: Float? = null,
    val posY: Float? = null
)



